package com.yunjian.admin.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yunjian.admin.config.RMSCacheListener;
import com.yunjian.admin.util.RequestUtil;
import com.yunjian.admin.vo.WebResult;
import com.yunjian.core.basic.model.SResource;
import com.yunjian.core.basic.model.SUser;
import com.yunjian.core.basic.service.CacheService;
import com.yunjian.core.basic.service.SResourceService;
import com.yunjian.core.basic.service.SUserService;
import com.yunjian.core.basic.vo.CacheType;

/**
 * 主控制器类，实现请求映射和用户菜单加载
 * 
 * @author admin
 */
@Controller
public class MainController {
	
	private final static Logger logger = LoggerFactory.getLogger(MainController.class);
	
	@Autowired
	private CacheService cacheService;
	@Autowired
	private SResourceService sResourceService;
	@Autowired
	private SUserService sUserService;
	
	@RequestMapping("/error/{path}")
	@ResponseBody
	public WebResult<String> errorHandler(@PathVariable String path) {
		WebResult<String> ret = new WebResult<String>();
		logger.info("error page - {}", path);
		if ("403".equals(path)) {
			return ret.setCoder(WebResult.Coder.C403);
		} else if ("500".equals(path)) {
			return ret.setCoder(WebResult.Coder.C500);
		}
		return ret.setCoder(WebResult.Coder.C404);
	}
	
}
